home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / program / oxcc1434.zip / SRC / OXANF.H < prev    next >
C/C++ Source or Header  |  1996-09-03  |  19KB  |  751 lines

  1. /* 
  2.     oxanf.h    -- v1.430 definition of architecture neutral format
  3.     
  4.     Copyright (c) 1995
  5.     Norman D. Culver dba
  6.     Oxbow Software
  7.     1323 S.E. 17th Street #662
  8.     Ft. Lauderdale, FL 33316
  9.     (954) 463-4754
  10.     ndc@icanect.net
  11.     All rights reserved.
  12.  
  13.  * Redistribution and use in source and binary forms are permitted
  14.  * provided that: (1) source distributions retain this entire copyright
  15.  * notice and comment, and (2) distributions including binaries display
  16.  * the following acknowledgement:  ``This product includes software
  17.  * developed by Norman D. Culver dba Oxbow Software''
  18.  * in the documentation or other materials provided with the distribution
  19.  * and in all advertising materials mentioning features or use of this
  20.  * software.
  21.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  22.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  23.  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  24.  
  25. */
  26.  
  27.  
  28. /* F_RETBITS */
  29. #define RET_VOID (0x01)
  30. #define RET_FLOAT (0x02)
  31. #define RET_STRUCT (0x04)
  32. #define RET_DOUBLE (0x08)
  33. #define RET_LDOUBLE (0x10)
  34. #define RET_UNSIGNED (0x20)
  35.  
  36. /* F_QUALBITS */
  37. #define QUAL_NEAR (0x01)
  38. #define QUAL_FAR (0x02)
  39. #define QUAL_SEG16 (0x04)
  40. #define QUAL_FAR16 (0x08)
  41. #define QUAL_ELLIPSIS (0x10)
  42. #define QUAL_CONST (0x20)
  43. #define QUAL_VOLATILE (0x40)
  44.  
  45. /* address types in 'atype' for gen_code */
  46. #define A_VALUE (0x0001)
  47. #define A_POINTER (0x0002)
  48. #define A_MEMADDR (0x0004)
  49. #define A_IMMED (0x0008)
  50. #define A_ABSOLUTE (0x0010)
  51. #define A_TEMP (0x0020)
  52. #define A_DATA (0x0040)
  53. #define A_AUTO (0x0080)
  54. #define A_EXTERN (0x0100)
  55. #define A_GLOBAL (0x0200)
  56. #define A_RET (0x0400)
  57. #define A_NOALIAS (0x0800)
  58. #define A_PARAM (0x1000)
  59.  
  60. /* data types in 'dtype'(low 8 bits) for gen_code */
  61. #define D_SIGNED (0x0000)
  62. #define D_UNSIGNED (0x0001)
  63. #define D_FLOAT (0x0002)
  64. #define D_POINTER (0x0003)
  65. #define D_ARRAY (0x0004)
  66. #define D_STRUCT (0x0005)
  67. #define D_FUNCTION (0x0006)
  68. #define D_FUNCPTR (0x0007)
  69. #define D_SEGMENT (0x0008)
  70.  
  71. /* data qualifiers in `dtype' (high 8 bits) for gen_code */
  72. #define Q_NEAR    (0x01)
  73. #define Q_FAR    (0x02)
  74. #define Q_HUGE    (0x04)
  75. #define Q_CONST    (0x08)
  76. #define Q_VOLAT (0x10)
  77. #define Q_SEG16    (0x20)
  78. #define Q_FAR16    (0x40)
  79. #define Q_BASED    (0x80)
  80.  
  81. /* in the opcode 3 address ids */
  82. #define OPIMMED1 (0x00)    /* signed integer type */
  83. #define OPIMMED2 (0x20)    /* unsigned integer type */
  84. #define OPIMMED3 (0x40) /* float type */
  85. #define OPIMMED4 (0x60) /* pointer type */
  86. #define OPTEMP (0x80)
  87. #define OPRET (0xa0)
  88. #define OPAUTO (0xc0)
  89. #define OPDATA (0xe0)
  90.  
  91. /* HARWARE TYPES */
  92. #define INTEL8616 'i'
  93. #define INTEL8632 'I'
  94. #define POWER_PC 'P'
  95. #define DEC_ALPHA 'D'
  96. #define PA_RISC 'H'
  97. #define MIPS_3000 'm'
  98. #define MIPS_4000 'M'
  99.  
  100. /* GENCODE TYPE */
  101. #define MACHINE_CODE 'm'
  102. #define SOURCE_CODE 's'
  103. #define BYTE_CODE 'b'
  104. #define RIP_CODE 'r'
  105. #define DEBUG_CODE 'd'
  106. #define ANF_CODE 'n'
  107. #define ASSEMBLER_CODE 'a'
  108.  
  109. /* OPERATING SYSTEM TYPES */
  110. #define DOS16PLAT 'd'
  111. #define DOS32PLAT 'D'
  112. #define WIN16PLAT 'w'
  113. #define WIN32sPLAT 'W'
  114. #define WIN32gPLAT 'C'
  115. #define WINntPLAT 'N'
  116. #define OS216PLAT 'o'
  117. #define OS232PLAT 'O'
  118. #define UNIXVPLAT 'U'
  119. #define LINUXPLAT 'L'
  120.  
  121. /* TARGET DEBUGGER INFO */
  122. #define CODEVBUG 'v'
  123. #define WATCBUG 'w'
  124. #define BORLBUG 'b'
  125. #define GDBBUG 'g'
  126. #define DWARF 'd'
  127.  
  128. /* TARGET ASSEMBLER INFO */
  129. #define UNIX 'u'
  130. #define GAS 'g'
  131. #define MASM 'm'
  132. #define TASM 't'
  133.  
  134. /* MEMORY MODELS */
  135. #define MODTINY 't'
  136. #define MODSMALL 's'
  137. #define MODMEDIUM 'm'
  138. #define MODLARGE 'l'
  139. #define MODCOMPACT 'c'
  140. #define MODHUGE 'h'
  141. #define MODFLAT 'x'
  142.  
  143. /* OBJECT FILE FORMATS */
  144. #define OMF16FORMAT 'o'
  145. #define OMF32FORMAT 'O'
  146. #define PHARLAPFORMAT 'P'
  147. #define WATCOM32FORMAT 'W'
  148. #define BORLAND32FORMAT 'B'
  149. #define AOUTFORMAT 'a'
  150. #define COFFFORMAT 'c'
  151. #define ELFFORMAT 'e'
  152.  
  153. #if NEED_FUNCTHUNK
  154.  
  155. /* FUNCTHUNK CONTENTS */
  156.  
  157. /* F_MODS */
  158. #define Fretvoid (0x0001)
  159. #define Fretflt (0x0002)
  160. #define Fretstr (0x0004)
  161. #define Fretdbl  (0x0008)
  162. #define Fretldbl (0x0010)
  163. #define Fbuiltin (0x0020)
  164. #define Funused1 (0x0040)
  165. #define Funused2 (0x0080)
  166. #define Fnear     (0x0100)
  167. #define Ffar     (0x0200)
  168. #define Fseg16  (0x0400)
  169. #define Ffar16  (0x0800)
  170. #define Fellipsis (0x1000)
  171. #define Fthunked (0x2000)
  172. #define Fnested (0x4000)
  173. #define Fextern (0x8000)
  174.  
  175. typedef struct _functhunk {/* 16 bytes */
  176.     long funcaddr;
  177.     unsigned short stksiz;
  178.     unsigned short argsiz;
  179.     unsigned short stkbeg;
  180.     unsigned short fmods;
  181.     unsigned short retsiz;
  182.     unsigned short maxes;
  183. } *Pft;
  184.  
  185. typedef union _datum { /* 16 bytes */
  186. #if SUPPORT_LONG_LONG
  187.     unsigned long long Uulonglong;
  188.     long long        Ulonglong;
  189. #endif
  190.     unsigned char    Uuchar;
  191.     char            Uchar;
  192.     unsigned short    Uushort;
  193.     short            Ushort;
  194.     unsigned int    Uuint;
  195.     int                Uint;
  196.     unsigned long    Uulong;
  197.     long            Ulong;
  198.     void *            Upointer;
  199.     float            Ufloat;
  200.     double            Udouble;
  201. #if SUPPORT_LONG_DOUBLE
  202.     long double        Ulongdouble;
  203. #endif
  204.     struct {
  205.         char d[16];
  206.     } chr;
  207.     struct {
  208.         unsigned char d[16];
  209.     } uchr;
  210.     struct {
  211.         short d[8];
  212.     } shrt;
  213.     struct {
  214.         unsigned short d[8];
  215.     } ushrt;
  216.     struct {
  217.         long d[4];
  218.     } lng;
  219.     struct {
  220.         unsigned long d[4];
  221.     } ulng;
  222. #if SUPPORT_LONG_LONG
  223.     struct {
  224.         long long d[2];
  225.     } lnglng;
  226.     struct {
  227.         unsigned long long d[2];
  228.     } ulnglng;
  229. #endif
  230.     struct {
  231.         void *d[4];
  232.     } ptr;
  233. } DATUM;
  234. #endif /* NEED_FUNCTHUNK */
  235.  
  236. #ifdef NEED_ANFDEFS
  237. enum basedecls {/* 1-21 */
  238.     bd_array = 1, bd_struct, bd_union, bd_function, bd_funcptr,
  239.     bd_pointer, bd_uchar, bd_ushort, bd_uint, bd_ulong,
  240.     bd_ulonglong, bd_float, bd_longdouble, bd_double, bd_char,
  241.     bd_short, bd_int, bd_long, bd_longlong, bd_void,
  242.     bd_segment
  243. };
  244.  
  245. typedef struct op {
  246.     unsigned char op;
  247.     unsigned char a1;
  248.     unsigned char a2;
  249.     unsigned char a3;
  250.     unsigned char *next;
  251.     long data;
  252.     long data1;
  253.     short data2;
  254.     unsigned short data3;
  255.     long data4;                /* perhaps skip to data in next area */
  256.     long data5;                /* NODEP in functhunk */
  257.     long data5a;            /* ARGSIZ|STKSIZ in functhunk */
  258.     unsigned short data6;    /* STKBEG in functhunk */
  259.     unsigned short data7;    /* F_MODS in functhunk */
  260.     unsigned short data8;    /* F_RETSIZ in functhunk */
  261.     unsigned short data9;    /* MAXES in functhunk */
  262. } *Pop;
  263. #define POP ((Pop)p)
  264.  
  265. typedef union opD {
  266.     unsigned char    Uuchar;
  267.     char            Uchar;
  268.     unsigned short    Uushort;
  269.     short            Ushort;
  270.     unsigned int    Uuint;
  271.     int                Uint;
  272.     unsigned long    Uulong;
  273.     long            Ulong;
  274.     void *            Upointer;
  275.     float            Ufloat;
  276.     double            Udouble;
  277. #if SUPPORT_LONG_LONG
  278.     unsigned long long Uulonglong;
  279.     long long        Ulonglong;
  280. #else
  281.     long            Ulonglong[2];
  282.     unsigned long    Uulonglong[2];
  283. #endif
  284. #if SUPPORT_LONG_DOUBLE
  285.     long double        Ulongdouble;
  286. #endif
  287. } opD, *PopD;
  288.  
  289. typedef struct opR {
  290.     unsigned short dtype;
  291.     unsigned short atype;
  292.     long dsize;
  293. } *PopR;
  294.  
  295. typedef struct opT {
  296.     unsigned short dtype;
  297.     unsigned short atype;
  298.     long dsize;
  299.     long tmpnum;
  300. } *PopT;
  301.  
  302. typedef struct opA {
  303.     unsigned short dtype;
  304.     unsigned short atype;
  305.     long dsize;
  306.     long offset;
  307.     unsigned short declnum;
  308.     short symnum;
  309.     long pofs;    /* autovars only */
  310. } *PopA;
  311. #define POPA ((PopA)(p+inc))
  312.  
  313. typedef struct _inst {
  314.     PopA lptr;
  315.     PopA rptr;
  316.     PopA dptr;
  317.     unsigned char loptype;
  318.     unsigned char roptype;
  319.     unsigned char doptype;
  320. } INST, *PINST;
  321.  
  322. typedef union opI {
  323.     struct  {
  324.         unsigned long total_size;
  325.         unsigned long thunk_offset;
  326.         unsigned long bss_offset;
  327.     } dat;
  328.     struct  {
  329.         unsigned long size;
  330.         unsigned long offset;
  331.         short symnum;
  332.         unsigned short declnum;
  333.         short segid;
  334.         unsigned short dtype;
  335.     } s;
  336.     struct {
  337.         unsigned short declnum;
  338.         unsigned short basedecl;
  339.     } dcl;
  340.     struct {
  341.         unsigned long swdefault;
  342.         unsigned long swnode;
  343.     } swt;
  344.     struct {
  345.         long argsize;
  346.         long bits;
  347.         long retbits;
  348.     } fc;
  349.     struct {
  350.         unsigned long size;
  351.         unsigned long offset;
  352.     } rs;
  353.     struct {
  354.         unsigned long argloc;
  355.         unsigned long argsize;
  356.     } arg;
  357.     struct {
  358.         unsigned long arysize;
  359.         unsigned long elemsize;
  360.         unsigned long dims1;
  361.         unsigned short dcnt;
  362.         unsigned short declnum;
  363.     } ary;
  364.     struct {
  365.         unsigned long dims[4